const {contextBridge, ipcRenderer} = require("electron")
contextBridge.exposeInMainWorld("myAPI", {
    version: process.version,
    saveFile: (data) => {
        ipcRenderer.send("save-file", data)
    },
    async readFile() {
        let txt = await ipcRenderer.invoke("read-file")
    }
})


window.addEventListener('DOMContentLoaded', () => {
    const replaceText = (selector, text) => {
        const element = document.getElementById(selector)
        if (element) element.innerText = text
    }
    for (const dependency of ['chrome', 'node', 'electron']) {
        replaceText(`${dependency}-version`, process.versions[dependency])
    }
})
